#!/bin/bash


service httpd stop      
service mysqld stop     
service crond stop      
yum remove php* -y      
yum remove mysql -y     
yum remove rsync -y     
yum remove subversion -y



yum install httpd -y

service httpd start

chkconfig httpd on

iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT

service iptables restart

yum install mysql mysql-server -y 

service mysqld start


chkconfig mysqld on


expect mysqlsecure.exp 




yum install php php-mysql php-imap -y


sed -i 's/\;date\.timezone\=/date\.timezone=\"Asia\/Dhaka\"/g' /etc/php.ini


service httpd restart


yum install rsync -y

yum install subversion -y

cd /opt

rm -rf svn

mkdir svn

cd svn

svn checkout https://bytefact-autores.googlecode.com/svn/trunk/

cd trunk

cp -r * /var/www/html


cp /var/www/html/autores_db.sql /root

cd /var/www/html/bytefact

chown -R  apache:apache images/
chown  apache:apache gplay.png

chown  apache:apache favicon.ico

cd

mysql -uroot  -pbyt3fact@4230 -Bse "DROP DATABASE autores_db;CREATE DATABASE autores_db;"

mysql -uroot  -pbyt3fact@4230 autores_db < autores_db.sql

mysql -uroot  -pbyt3fact@4230 -Bse "use autores_db;delete from alias_mail;
delete from campaign;
delete from delay_message;
delete from delay_message_attachment;
delete from mails;
delete from message;
delete from message_attachment;
delete from send_delay_mail;
delete from send_mail;
delete from sub_master_mail;
insert into mails(id) values('total');
delete from client_info;"




mv /etc/localtime /etc/localtime.bak

ln -s /usr/share/zoneinfo/Asia/Dhaka /etc/localtime


crontab -l | { cat; echo "*/1 * * * *  curl -l "http://$HOSTNAME.work/scheduler/fetcher/test.php" >> /var/log/fetcher.log 2>&1"; } | crontab -


crontab -l | { cat; echo "*/1 * * * *  curl -l "http://$HOSTNAME.work/scheduler/sender/test.php" >> /var/log/sernder.log 2>&1"; } | crontab -

5 0 * * *  curl -l "http://$HOSTNAME.work/scheduler/sender/delete.php" > /var/log/delete.log 2>&1

crontab -l | { cat; echo "*/3 * * * *  echo 3 > /proc/sys/vm/drop_caches"; } | crontab -


rm -rf /var/www/html/autores_db.sql

service crond restart

service httpd restart

service mysqld restart

echo "Server setup completed"


